package com.xiaoshuidi.cloud.module.rooms.controller.admin.floor;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.floor.vo.AddFloorReqVo;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.floor.vo.AddFloorRespVo;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.floor.vo.EditFloorRespVo;
import com.xiaoshuidi.cloud.module.rooms.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.rooms.service.RoomFloorService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "管理后台 - 楼层管理")
@RestController
@RequestMapping(ApiConstants.NAME + "/roomfloor")
@RequiredArgsConstructor
public class FloorController {

    private final RoomFloorService roomFloorService;

    @Operation(summary = "修改楼层名称")
    @PutMapping("/edit")
    @Parameters({
            @Parameter(name = "floorId", description = "楼层id"),
            @Parameter(name = "num", description = "楼层")
    })
    public CommonResult<EditFloorRespVo> edit(@RequestParam("floorId") Long floorId, @RequestParam("num") Integer num){
        Long userId = SecurityFrameworkUtils.getLoginUserId();
        return roomFloorService.edit(floorId, num, userId);
    }

    @Operation(summary = "删除楼层")
    @Parameters({
            @Parameter(name = "floorId", description = "楼层id"),
    })
    @DeleteMapping
    public CommonResult<Boolean> delete(@RequestParam("floorId") Long floorId){
        Long userId = SecurityFrameworkUtils.getLoginUserId();
        return roomFloorService.delete(floorId, userId);
    }

}
